package com.pubg.information.config;

import com.pubg.information.component.LoginHandleInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyMvcConfig implements WebMvcConfigurer {
    //视图解析器
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("main.html").setViewName("main");
        registry.addViewController("login.html").setViewName("login");
        registry.addViewController("personal.html").setViewName("personal");
        registry.addViewController("redic.html").setViewName("redic");
    }
    //注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginHandleInterceptor()).addPathPatterns("/main.html","/personal","/modifying","/file");
    }
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/img/portrait/**").addResourceLocations("file:C:/img/");
        registry.addResourceHandler("/video/**").addResourceLocations("file:C:/video/");
    }
}
